import DownloadTaskAPI from "@/api/downloadTask/index";
import type {DownloadTaskQuery} from "@/api/downloadTask/model";
import type {IContentConfig} from "@/components/PageContent/index.vue";

const contentConfig: IContentConfig<DownloadTaskQuery> = {
    pageName: "user:downloadTask",
    table: {
        border: true,
        highlightCurrentRow: true,
    },
    indexAction: function (params) {
        if ("createAt" in params) {
            const createAt = params.createAt as string[];
            params.startTimeBegin = createAt[0];
            params.startTimeEnd = createAt[1];
            delete params.createAt;
        }
        return DownloadTaskAPI.listPage(params);
    },
    pk: "taskId",
    toolbar: [],
    cols: [
        {width: 180,label: "编号", align: "center", prop: "taskId"},
        {label: "文件名", align: "center", prop: "fileName", expand: true},
        {width: 180,label: "创建时间", align: "center", prop: "startTime", template: "date", dateFormat: "YYYY-MM-DD HH:mm:ss"},
        {width: 180,label: "预计执行时间", align: "center", prop: "awaitTime"},
        {width: 180,label: "完成时间", align: "center", prop: "endTime", template: "date", dateFormat: "YYYY-MM-DD HH:mm:ss"},
        {label: "推迟执行原因", align: "center", prop: "awaitReason", expand: true},

        {label: "进度", align: "center", prop: "taskProgress", width: 80, template: "percent"},
        {label: "耗时", align: "center", prop: "usingTime", width: 80, template: "custom", slotName: 'usingTime'},
        {label: "发起人", align: "center", prop: "operator", width: 100},
        {label: "状态", align: "center", prop: "taskStatus", template: "custom", slotName: "taskStatus"},
        {label: "备注", align: "center", prop: "remark"},
        // { label: "运行结果", align: "center", prop: "msg", width: 120 ,show:false},
        {
            label: "操作",
            fixed: "right",
            width: 130,
            align: "center",
            template: "custom",
            slotName: 'tool'
        },
    ],
};

export default contentConfig;
